package userInterfaces;

import java.io.IOException;
import java.util.List;

import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;

import managerBean.CarrelloManagerBean;
import model.Pacchetto;

@ManagedBean(name="CarrelloManagedBean")
@ViewScoped
public class CarrelloManagedBean {
	
	@EJB
	private CarrelloManagerBean carrMgrBean;
	
	private List<Pacchetto> pacchetti;

	public CarrelloManagedBean() {
		super();
	}

	public List<Pacchetto> getPacchetti() {
		this.pacchetti=carrMgrBean.getPacchettiMgr();
		return pacchetti;
	}

	public void setPacchetti(List<Pacchetto> pacchetti) {
		this.pacchetti = pacchetti;
	}
	
	public void rimuoviPacchetto(int idPacchetto){
		carrMgrBean.rimuoviPacchettoMgr(idPacchetto);
	}
	public void svuotaCarrello(){
		carrMgrBean.svuotaCarrelloMgr();
		try {
			FacesContext.getCurrentInstance().getExternalContext().redirect("../home.xhtml");
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}
		

}
